sched: rework credit2 run-queue allocation
authorJuergen Gross <jgross@suse.com>
Wed, 26 Feb 2020 09:50:26 +0000 (10:50 +0100)
committerJan Beulich <jbeulich@suse.com>
Wed, 26 Feb 2020 09:50:26 +0000 (10:50 +0100)
commit9c84bc0046536bef202176b2b43038dc5d2ebf6e
treee8cc8b1d61b81907477f01342e74a1af7af2936f
parentd90bcb5f10995c52d080274d66bfdc362b22598e
sched: rework credit2 run-queue allocation

Currently the memory for each run-queue of the credit2 scheduler is
allocated at the scheduler's init function: for each cpu in the system
a struct csched2_runqueue_data is being allocated, even if the
current scheduler only handles one physical cpu or is configured to
work with a single run-queue. As each struct contains 4 cpumasks this
sums up to rather large memory sizes pretty fast.

Rework the memory allocation for run-queues to be done only when
needed, i.e. when adding a physical cpu to the scheduler requiring a
new run-queue.

In fact this fixes a bug in credit2 related to run-queue handling:
cpu_to_runqueue() will return the first free or matching run-queue,
which ever is found first. So in case a cpu is removed from credit2
this could result in e.g. run-queue 0 becoming free, so when another
cpu is added it will in any case be assigned to that free run-queue,
even if it would have found another run-queue matching later.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Dario Faggioli <dfaggioli@suse.com>
xen/common/sched/credit2.c